//
//  KZUserHeaderView.m
//  听说弱点强化训练
//
//  Created by 朱凯 on 2018/9/4.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "KZUserHeaderView.h"

@implementation KZUserHeaderView
{
    UIImageView *_iconView;     // 头像
    UILabel     *_nickLabel;    // 昵称
    UILabel     *_noLabel;      // 学号
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    self.image = [UIImage imageNamed:@"kz-个人中心顶部背景图"];
    
    _iconView = [UIImageView new];
    _iconView.layer.cornerRadius = H(70)/2;
    _iconView.layer.masksToBounds = true;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:DR_UserInfo.PhotoPath] placeholderImage:[UIImage imageNamed:@"kz-默认头像"]];
    [self addSubview:_iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY).offset(10);
        make.width.height.mas_equalTo(H(70));
        make.left.mas_equalTo(W(20));
    }];
    
    _nickLabel = [[UILabel alloc] init];
    _nickLabel.text = DR_UserInfo.UserName;
    _nickLabel.font = B_FONT(17);
    _nickLabel.textAlignment = NSTextAlignmentLeft;
    _nickLabel.textColor = [UIColor whiteColor];
    [self addSubview:_nickLabel];
    [_nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconView.mas_right).offset(W(20));
        make.bottom.equalTo(_iconView.mas_centerY).offset(-H(3));
    }];
    
    _noLabel = [[UILabel alloc] init];
    _noLabel.text = [NSString stringWithFormat:@"学号：%@", DR_UserInfo.UserID];
    _noLabel.font = FONT(12);
    _noLabel.textAlignment = NSTextAlignmentLeft;
    _noLabel.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
    [self addSubview:_noLabel];
    [_noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nickLabel);
        make.top.equalTo(_nickLabel.mas_bottom).offset(H(6));
    }];
}

@end
